home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK2.toast / Development Kits (Disc 2) / QuickTime / QuickTime™ 2.5 / Interfaces for Programmers / CIncludes / ImageCodec.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-26  |  14.1 KB  |  392 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        ImageCodec.h
  3.  
  4.      Contains:    QuickTime interfaces
  5.  
  6.      Version:    Technology:    
  7.                  Release:    QuickTime 2.5 interfaces to use with ETO #20
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __IMAGECODEC__
  19. #define __IMAGECODEC__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __QUICKDRAW__
  25. #include <Quickdraw.h>
  26. #endif
  27. #ifndef __QDOFFSCREEN__
  28. #include <QDOffscreen.h>
  29. #endif
  30. #ifndef __WINDOWS__
  31. #include <Windows.h>
  32. #endif
  33. #ifndef __IMAGECOMPRESSION__
  34. #include <ImageCompression.h>
  35. #endif
  36. #ifndef __COMPONENTS__
  37. #include <Components.h>
  38. #endif
  39. #ifndef __MOVIES__
  40. #include <Movies.h>
  41. #endif
  42.  
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46.  
  47. #if PRAGMA_IMPORT_SUPPORTED
  48. #pragma import on
  49. #endif
  50.  
  51. #if PRAGMA_ALIGN_SUPPORTED
  52. #pragma options align=mac68k
  53. #endif
  54.  
  55. /*    codec capabilities flags    */
  56.  
  57. enum {
  58.     codecCanScale                = 1L << 0,
  59.     codecCanMask                = 1L << 1,
  60.     codecCanMatte                = 1L << 2,
  61.     codecCanTransform            = 1L << 3,
  62.     codecCanTransferMode        = 1L << 4,
  63.     codecCanCopyPrev            = 1L << 5,
  64.     codecCanSpool                = 1L << 6,
  65.     codecCanClipVertical        = 1L << 7,
  66.     codecCanClipRectangular        = 1L << 8,
  67.     codecCanRemapColor            = 1L << 9,
  68.     codecCanFastDither            = 1L << 10,
  69.     codecCanSrcExtract            = 1L << 11,
  70.     codecCanCopyPrevComp        = 1L << 12,
  71.     codecCanAsync                = 1L << 13,
  72.     codecCanMakeMask            = 1L << 14,
  73.     codecCanShift                = 1L << 15,
  74.     codecCanAsyncWhen            = 1L << 16,
  75.     codecCanShieldCursor        = 1L << 17,
  76.     codecCanManagePrevBuffer    = 1L << 18,
  77.     codecHasVolatileBuffer        = 1L << 19,
  78.     codecWantsRegionMask        = 1L << 20,
  79.     codecImageBufferIsOnScreen    = 1L << 21,
  80.     codecWantsDestinationPixels    = 1L << 22
  81. };
  82.  
  83. struct CodecCapabilities {
  84.     long                             flags;
  85.     short                             wantedPixelSize;
  86.     short                             extendWidth;
  87.     short                             extendHeight;
  88.     short                             bandMin;
  89.     short                             bandInc;
  90.     short                             pad;
  91.     unsigned long                     time;
  92. };
  93. typedef struct CodecCapabilities CodecCapabilities;
  94.  
  95. /*    codec condition flags    */
  96.  
  97. enum {
  98.     codecConditionFirstBand        = 1L << 0,
  99.     codecConditionLastBand        = 1L << 1,
  100.     codecConditionFirstFrame    = 1L << 2,
  101.     codecConditionNewDepth        = 1L << 3,
  102.     codecConditionNewTransform    = 1L << 4,
  103.     codecConditionNewSrcRect    = 1L << 5,
  104.     codecConditionNewMask        = 1L << 6,
  105.     codecConditionNewMatte        = 1L << 7,
  106.     codecConditionNewTransferMode = 1L << 8,
  107.     codecConditionNewClut        = 1L << 9,
  108.     codecConditionNewAccuracy    = 1L << 10,
  109.     codecConditionNewDestination = 1L << 11,
  110.     codecConditionFirstScreen    = 1L << 12,
  111.     codecConditionDoCursor        = 1L << 13,
  112.     codecConditionCatchUpDiff    = 1L << 14,
  113.     codecConditionMaskMayBeChanged = 1L << 15,
  114.     codecConditionToBuffer        = 1L << 16,
  115.     codecConditionCodecChangedMask = 1L << 31
  116. };
  117.  
  118.  
  119. enum {
  120.     codecInfoResourceType        = 'cdci',                        /* codec info resource type */
  121.     codecInterfaceVersion        = 2                                /* high word returned in component GetVersion */
  122. };
  123.  
  124. struct CDSequenceDataSource {
  125.     long                             recordSize;
  126.  
  127.     void *                            next;
  128.  
  129.     ImageSequence                     seqID;
  130.     ImageSequenceDataSource         sourceID;
  131.     OSType                             sourceType;
  132.     long                             sourceInputNumber;
  133.     void *                            dataPtr;
  134.     Handle                             dataDescription;
  135.     long                             changeSeed;
  136.     ICMConvertDataFormatUPP         transferProc;
  137.     void *                            transferRefcon;
  138.     long                             dataSize;
  139. };
  140. typedef struct CDSequenceDataSource CDSequenceDataSource;
  141.  
  142. typedef CDSequenceDataSource *CDSequenceDataSourcePtr;
  143. struct CodecCompressParams {
  144.     ImageSequence                     sequenceID;                    /* precompress,bandcompress */
  145.     ImageDescriptionHandle             imageDescription;            /* precompress,bandcompress */
  146.     Ptr                             data;
  147.     long                             bufferSize;
  148.     long                             frameNumber;
  149.     long                             startLine;
  150.     long                             stopLine;
  151.     long                             conditionFlags;
  152.     CodecFlags                         callerFlags;
  153.     CodecCapabilities *                capabilities;                /* precompress,bandcompress */
  154.     ICMProgressProcRecord             progressProcRecord;
  155.     ICMCompletionProcRecord         completionProcRecord;
  156.     ICMFlushProcRecord                 flushProcRecord;
  157.  
  158.     PixMap                             srcPixMap;                    /* precompress,bandcompress */
  159.     PixMap                             prevPixMap;
  160.     CodecQ                             spatialQuality;
  161.     CodecQ                             temporalQuality;
  162.     Fixed                             similarity;
  163.     DataRateParamsPtr                 dataRateParams;
  164.     long                             reserved;
  165.  
  166.                                                                 /* The following fields only exist for QuickTime 2.1 and greater */
  167.     UInt16                             majorSourceChangeSeed;
  168.     UInt16                             minorSourceChangeSeed;
  169.     CDSequenceDataSourcePtr         sourceData;
  170.  
  171.                                                                 /* The following fields only exit for QuickTime 2.5 and greater */
  172.     long                             preferredPacketSizeInBytes;
  173. };
  174. typedef struct CodecCompressParams CodecCompressParams;
  175.  
  176. struct CodecDecompressParams {
  177.     ImageSequence                     sequenceID;                    /* predecompress,banddecompress */
  178.     ImageDescriptionHandle             imageDescription;            /* predecompress,banddecompress */
  179.     Ptr                             data;
  180.     long                             bufferSize;
  181.     long                             frameNumber;
  182.     long                             startLine;
  183.     long                             stopLine;
  184.     long                             conditionFlags;
  185.     CodecFlags                         callerFlags;
  186.     CodecCapabilities *                capabilities;                /* predecompress,banddecompress */
  187.     ICMProgressProcRecord             progressProcRecord;
  188.     ICMCompletionProcRecord         completionProcRecord;
  189.     ICMDataProcRecord                 dataProcRecord;
  190.  
  191.     CGrafPtr                         port;                        /* predecompress,banddecompress */
  192.     PixMap                             dstPixMap;                    /* predecompress,banddecompress */
  193.     BitMapPtr                         maskBits;
  194.     PixMapPtr                         mattePixMap;
  195.     Rect                             srcRect;                    /* predecompress,banddecompress */
  196.     MatrixRecord *                    matrix;                        /* predecompress,banddecompress */
  197.     CodecQ                             accuracy;                    /* predecompress,banddecompress */
  198.     short                             transferMode;                /* predecompress,banddecompress */
  199.     ICMFrameTimePtr                 frameTime;                    /* banddecompress */
  200.     long                             reserved[1];
  201.                                                                 /* The following fields only exist for QuickTime 2.0 and greater */
  202.     SInt8                             matrixFlags;                /* high bit set if 2x resize */
  203.     SInt8                             matrixType;
  204.     Rect                             dstRect;                    /* only valid for simple transforms */
  205.                                                                 /* The following fields only exist for QuickTime 2.1 and greater */
  206.     UInt16                             majorSourceChangeSeed;
  207.     UInt16                             minorSourceChangeSeed;
  208.     CDSequenceDataSourcePtr         sourceData;
  209.  
  210.     RgnHandle                         maskRegion;
  211.  
  212.                                                                 /* The following fields only exist for QuickTime 2.5 and greater */
  213.  
  214.     OSType **                        wantedDestinationPixelTypes; /* Handle to 0-terminated list of OSTypes */
  215.  
  216.     long                             screenFloodMethod;
  217.     long                             screenFloodValue;
  218.     short                             preferredOffscreenPixelSize;
  219. };
  220. typedef struct CodecDecompressParams CodecDecompressParams;
  221.  
  222.  
  223. enum {
  224.     matrixFlagScale2x            = 1L << 7,
  225.     matrixFlagScale1x            = 1L << 6,
  226.     matrixFlagScaleHalf            = 1L << 5
  227. };
  228.  
  229.  
  230. enum {
  231.     kScreenFloodMethodNone        = 0,
  232.     kScreenFloodMethodKeyColor    = 1,
  233.     kScreenFloodMethodAlpha        = 2
  234. };
  235.  
  236. /*    codec selectors 0-127 are reserved by Apple */
  237. /*    codec selectors 128-191 are subtype specific */
  238. /*    codec selectors 192-255 are vendor specific */
  239. /*    codec selectors 256-32767 are available for general use */
  240. /*    negative selectors are reserved by the Component Manager */
  241. extern pascal ComponentResult ImageCodecGetCodecInfo(ComponentInstance ci, CodecInfo *info)
  242.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x0000, 0x7000, 0xA82A);
  243.  
  244. extern pascal ComponentResult ImageCodecGetCompressionTime(ComponentInstance ci, PixMapHandle src, const Rect *srcRect, short depth, CodecQ *spatialQuality, CodecQ *temporalQuality, unsigned long *time)
  245.  FIVEWORDINLINE(0x2F3C, 0x0016, 0x0001, 0x7000, 0xA82A);
  246.  
  247. extern pascal ComponentResult ImageCodecGetMaxCompressionSize(ComponentInstance ci, PixMapHandle src, const Rect *srcRect, short depth, CodecQ quality, long *size)
  248.  FIVEWORDINLINE(0x2F3C, 0x0012, 0x0002, 0x7000, 0xA82A);
  249.  
  250. extern pascal ComponentResult ImageCodecPreCompress(ComponentInstance ci, CodecCompressParams *params)
  251.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x0003, 0x7000, 0xA82A);
  252.  
  253. extern pascal ComponentResult ImageCodecBandCompress(ComponentInstance ci, CodecCompressParams *params)
  254.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x0004, 0x7000, 0xA82A);
  255.  
  256. extern pascal ComponentResult ImageCodecPreDecompress(ComponentInstance ci, CodecDecompressParams *params)
  257.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x0005, 0x7000, 0xA82A);
  258.  
  259. extern pascal ComponentResult ImageCodecBandDecompress(ComponentInstance ci, CodecDecompressParams *params)
  260.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x0006, 0x7000, 0xA82A);
  261.  
  262. extern pascal ComponentResult ImageCodecBusy(ComponentInstance ci, ImageSequence seq)
  263.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x0007, 0x7000, 0xA82A);
  264.  
  265. extern pascal ComponentResult ImageCodecGetCompressedImageSize(ComponentInstance ci, ImageDescriptionHandle desc, Ptr data, long bufferSize, ICMDataProcRecordPtr dataProc, long *dataSize)
  266.  FIVEWORDINLINE(0x2F3C, 0x0014, 0x0008, 0x7000, 0xA82A);
  267.  
  268. extern pascal ComponentResult ImageCodecGetSimilarity(ComponentInstance ci, PixMapHandle src, const Rect *srcRect, ImageDescriptionHandle desc, Ptr data, Fixed *similarity)
  269.  FIVEWORDINLINE(0x2F3C, 0x0014, 0x0009, 0x7000, 0xA82A);
  270.  
  271. extern pascal ComponentResult ImageCodecTrimImage(ComponentInstance ci, ImageDescriptionHandle Desc, Ptr inData, long inBufferSize, ICMDataProcRecordPtr dataProc, Ptr outData, long outBufferSize, ICMFlushProcRecordPtr flushProc, Rect *trimRect, ICMProgressProcRecordPtr progressProc)
  272.  FIVEWORDINLINE(0x2F3C, 0x0024, 0x000A, 0x7000, 0xA82A);
  273.  
  274. extern pascal ComponentResult ImageCodecRequestSettings(ComponentInstance ci, Handle settings, Rect *rp, ModalFilterUPP filterProc)
  275.  FIVEWORDINLINE(0x2F3C, 0x000C, 0x000B, 0x7000, 0xA82A);
  276.  
  277. extern pascal ComponentResult ImageCodecGetSettings(ComponentInstance ci, Handle settings)
  278.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x000C, 0x7000, 0xA82A);
  279.  
  280. extern pascal ComponentResult ImageCodecSetSettings(ComponentInstance ci, Handle settings)
  281.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x000D, 0x7000, 0xA82A);
  282.  
  283. extern pascal ComponentResult ImageCodecFlush(ComponentInstance ci)
  284.  FIVEWORDINLINE(0x2F3C, 0x0000, 0x000E, 0x7000, 0xA82A);
  285.  
  286. extern pascal ComponentResult ImageCodecSetTimeCode(ComponentInstance ci, void *timeCodeFormat, void *timeCodeTime)
  287.  FIVEWORDINLINE(0x2F3C, 0x0008, 0x000F, 0x7000, 0xA82A);
  288.  
  289. extern pascal ComponentResult ImageCodecIsImageDescriptionEquivalent(ComponentInstance ci, ImageDescriptionHandle newDesc, Boolean *equivalent)
  290.  FIVEWORDINLINE(0x2F3C, 0x0008, 0x0010, 0x7000, 0xA82A);
  291.  
  292. extern pascal ComponentResult ImageCodecNewMemory(ComponentInstance ci, Ptr *data, Size dataSize, long dataUse, ICMMemoryDisposedUPP memoryGoneProc, void *refCon)
  293.  FIVEWORDINLINE(0x2F3C, 0x0014, 0x0011, 0x7000, 0xA82A);
  294.  
  295. extern pascal ComponentResult ImageCodecDisposeMemory(ComponentInstance ci, Ptr data)
  296.  FIVEWORDINLINE(0x2F3C, 0x0004, 0x0012, 0x7000, 0xA82A);
  297.  
  298. extern pascal ComponentResult ImageCodecHitTestData(ComponentInstance ci, ImageDescriptionHandle desc, void *data, Size dataSize, Point where, Boolean *hit)
  299.  FIVEWORDINLINE(0x2F3C, 0x0014, 0x0013, 0x7000, 0xA82A);
  300.  
  301. extern pascal ComponentResult ImageCodecNewImageBufferMemory(ComponentInstance ci, CodecDecompressParams *params, long flags, ICMMemoryDisposedUPP memoryGoneProc, void *refCon)
  302.  FIVEWORDINLINE(0x2F3C, 0x0010, 0x0014, 0x7000, 0xA82A);
  303.  
  304. extern pascal ComponentResult ImageCodecExtractAndCombineFields(ComponentInstance ci, long fieldFlags, void *data1, long dataSize1, ImageDescriptionHandle desc1, void *data2, long dataSize2, ImageDescriptionHandle desc2, void *outputData, long *outDataSize, ImageDescriptionHandle descOut)
  305.  FIVEWORDINLINE(0x2F3C, 0x0028, 0x0015, 0x7000, 0xA82A);
  306.  
  307. extern pascal ComponentResult ImageCodecGetMaxCompressionSizeWithSources(ComponentInstance ci, PixMapHandle src, const Rect *srcRect, short depth, CodecQ quality, CDSequenceDataSourcePtr sourceData, long *size)
  308.  FIVEWORDINLINE(0x2F3C, 0x0016, 0x0016, 0x7000, 0xA82A);
  309.  
  310.  
  311. /* selectors for component calls */
  312. enum {
  313.     kImageCodecGetCodecInfoSelect                    = 0x0000,
  314.     kImageCodecGetCompressionTimeSelect                = 0x0001,
  315.     kImageCodecGetMaxCompressionSizeSelect            = 0x0002,
  316.     kImageCodecPreCompressSelect                    = 0x0003,
  317.     kImageCodecBandCompressSelect                    = 0x0004,
  318.     kImageCodecPreDecompressSelect                    = 0x0005,
  319.     kImageCodecBandDecompressSelect                    = 0x0006,
  320.     kImageCodecBusySelect                            = 0x0007,
  321.     kImageCodecGetCompressedImageSizeSelect            = 0x0008,
  322.     kImageCodecGetSimilaritySelect                    = 0x0009,
  323.     kImageCodecTrimImageSelect                        = 0x000A,
  324.     kImageCodecRequestSettingsSelect                = 0x000B,
  325.     kImageCodecGetSettingsSelect                    = 0x000C,
  326.     kImageCodecSetSettingsSelect                    = 0x000D,
  327.     kImageCodecFlushSelect                            = 0x000E,
  328.     kImageCodecSetTimeCodeSelect                    = 0x000F,
  329.     kImageCodecIsImageDescriptionEquivalentSelect    = 0x0010,
  330.     kImageCodecNewMemorySelect                        = 0x0011,
  331.     kImageCodecDisposeMemorySelect                    = 0x0012,
  332.     kImageCodecHitTestDataSelect                    = 0x0013,
  333.     kImageCodecNewImageBufferMemorySelect            = 0x0014,
  334.     kImageCodecExtractAndCombineFieldsSelect        = 0x0015,
  335.     kImageCodecGetMaxCompressionSizeWithSourcesSelect = 0x0016
  336. };
  337.  
  338. enum {
  339.     kMotionJPEGTag                = 'mjpg'
  340. };
  341.  
  342. struct MotionJPEGApp1Marker {
  343.     long                             unused;
  344.     long                             tag;
  345.     long                             fieldSize;
  346.     long                             paddedFieldSize;
  347.     long                             offsetToNextField;
  348.     long                             qTableOffset;
  349.     long                             huffmanTableOffset;
  350.     long                             sofOffset;
  351.     long                             sosOffset;
  352.     long                             soiOffset;
  353. };
  354. typedef struct MotionJPEGApp1Marker MotionJPEGApp1Marker;
  355.  
  356. extern pascal ComponentResult QTPhotoSetSampling(ComponentInstance codec, short yH, short yV, short cbH, short cbV, short crH, short crV)
  357.  FIVEWORDINLINE(0x2F3C, 0x000C, 0x0100, 0x7000, 0xA82A);
  358.  
  359. extern pascal ComponentResult QTPhotoSetRestartInterval(ComponentInstance codec, unsigned short restartInterval)
  360.  FIVEWORDINLINE(0x2F3C, 0x0002, 0x0101, 0x7000, 0xA82A);
  361.  
  362. extern pascal ComponentResult QTPhotoDefineHuffmanTable(ComponentInstance codec, short componentNumber, Boolean isDC, unsigned char *lengthCounts, unsigned char *values)
  363.  FIVEWORDINLINE(0x2F3C, 0x000C, 0x0102, 0x7000, 0xA82A);
  364.  
  365. extern pascal ComponentResult QTPhotoDefineQuantizationTable(ComponentInstance codec, short componentNumber, unsigned char *table)
  366.  FIVEWORDINLINE(0x2F3C, 0x0006, 0x0103, 0x7000, 0xA82A);
  367.  
  368.  
  369. /* selectors for component calls */
  370. enum {
  371.     kQTPhotoSetSamplingSelect                        = 0x0100,
  372.     kQTPhotoSetRestartIntervalSelect                = 0x0101,
  373.     kQTPhotoDefineHuffmanTableSelect                = 0x0102,
  374.     kQTPhotoDefineQuantizationTableSelect            = 0x0103
  375. };
  376. /* UPP call backs */
  377.  
  378. #if PRAGMA_ALIGN_SUPPORTED
  379. #pragma options align=reset
  380. #endif
  381.  
  382. #if PRAGMA_IMPORT_SUPPORTED
  383. #pragma import off
  384. #endif
  385.  
  386. #ifdef __cplusplus
  387. }
  388. #endif
  389.  
  390. #endif /* __IMAGECODEC__ */
  391.  
  392.